/*==================================================================================================
  Description
  
  20080720      Wim       Created
==================================================================================================*/
/*global $, document, console, window
*/


/*==================================================================================================
  Description
  
  20080720      Wim       Created
==================================================================================================*/
(function ()
{
  var drop1 = null;
  var drop2 = null;
  var drop3 = null;
  var dragger = null;
  
  
  function onEnter(element, droppable)
  {
    //droppable.set({'text': 'Drop hier'});
    droppable.wb_background = droppable.getStyle('backgroundColor');
    droppable.setStyle('backgroundColor', 'red');
  }
  
  function onLeave(element, droppable)
  {
    //droppable.set('text', '');
    droppable.setStyle('backgroundColor', droppable.wb_background);
  }
  
  function onDrop(element, droppable)
  {
    if (droppable)
    {
      //droppable.set('text', 'YEAH');
    }
  }
  
  function setupEvent(droppable)
  {
    droppable.addEvent('over', function (element)
    {
      onEnter(element, droppable);
    });
    droppable.addEvent('leave', function (element)
    {
      onLeave(element, droppable);
    });
    droppable.addEvent('drop', function (element)
    {
      onDrop(element, droppable);
    });
  }

  function setupMoo11()
  {
    setupEvent(drop1);
    setupEvent(drop2);
    setupEvent(drop3);
  }
  
  function init()
  {
    drop1 = $('drop1');
    drop2 = $('drop2');
    drop3 = $('drop3');
    dragger = $('dragme');
    
    setupMoo11();
    dragger.makeDraggable(
    {
      snap: 10,
      droppables: '.drop',
      onEnter: function (element, droppable)
      {
        droppable.set('text', 'Drop hier');
        droppable.wb_background = droppable.getStyle('backgroundColor');
        droppable.setStyle('backgroundColor', 'red');
      },
      onLeave: function (element, droppable)
      {
        droppable.set('text', '');
        droppable.setStyle('backgroundColor', droppable.wb_background);
      },
      onDrop: function (element, droppable)
      {
        if (droppable)
        {
          droppable.set('text', 'YEAH');
        }
      }
    });
  }
  window.addEvent('domready', init);
})();
